package com.mengdie.shuidi.ui.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.mengdie.shuidi.AppContext;
import com.mengdie.shuidi.R;
import com.mengdie.shuidi.event.RegisterEvent;

import org.greenrobot.eventbus.EventBus;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * Created by apple on 16/10/12.
 */

public class RegistSuccessActivity extends BaseActivity {


    private static final String TAG = "RegistSuccessActivity";
    private static final String TAG1 = "RegistSuccessActivity1";
    private static final String TAGTYPE = "RegistsType";
    @Bind(R.id.rl_generic_back)
    RelativeLayout mRlGenericBack;
    @Bind(R.id.tv_generic_title)
    TextView mTvGenericTitle;
    @Bind(R.id.tv_regist_login)
    TextView mTvRegistLogin;

    @Bind(R.id.tv_type_text)
    TextView mTypetv;
    private String mUseName;
    private String mPassWord;
    private String mReGisType;
    public static Intent newIntent(String useName,String passWord,String type) {

        Intent intent = new Intent();
        intent.setClass(AppContext.getInstance(), RegistSuccessActivity.class);
        intent.putExtra(TAG, useName);
        intent.putExtra(TAG1, passWord);
        intent.putExtra(TAGTYPE,type);
        return intent;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_regist_success);
        ButterKnife.bind(this);
        init();
    }

    public void init() {
        mTvGenericTitle.setText("注册成功");
        Intent intent = getIntent();
        mUseName = intent.getStringExtra(TAG);
        mPassWord = intent.getStringExtra(TAG1);
        mReGisType = intent.getStringExtra(TAGTYPE);
        if(mReGisType.equals("1")){
          mTypetv.setText("恭喜您获得免费时长");
        }
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
    }


    @OnClick({R.id.rl_generic_back, R.id.tv_regist_login})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.rl_generic_back:
                EventBus.getDefault().post(new RegisterEvent(mUseName,mPassWord,true));
                finish();
                break;
            case R.id.tv_regist_login:
                EventBus.getDefault().post(new RegisterEvent(mUseName,mPassWord,true));
                finish();
                break;
        }
    }
}
